module timer_change(
	input clk_51200Hz,
	input rst_n,
	input[5:0] minute,
	input[5:0] second,
	output reg[15:0] temp,
	output reg[23:0] led_state
);

	integer i;
	reg[5:0] min;
	reg[5:0] sec;
	reg[15:0] led_temp;

	always @(posedge clk_51200Hz or negedge rst_n) begin
		if(rst_n == 1'b0) begin
			min = 6'd0;
			sec = 6'd0;
			led_temp = 16'd0;
			led_state = 24'd0;
		end
		else begin
			led_temp = 16'd0;
			min = minute;
			sec = second;
			/*
			led_temp[1:0] = sec % 3;
			led_temp[9:8] = min % 3;
			//led_temp = led_temp >> 2;
			sec = sec / 3;
			min = min / 3;
			led_temp[3:2] = sec % 3;
			led_temp[11:10] = min % 3;
			//led_temp = led_temp >> 2;
			sec = sec / 3;
			min = min / 3;
			led_temp[5:4] = sec % 3;
			led_temp[13:12] = min % 3;
			//led_temp = led_temp >> 2;
			sec = sec / 3;
			min = min / 3;
			led_temp[7:6] = sec % 3;
			led_temp[15:14] = min % 3;
			//led_temp = led_temp >> 2;
			//sec = sec / 3;
			//min = min / 3;
			*/
			
			for(i = 0; i < 4; i = i+1) begin
				//temp = sec % 3;
				led_temp[7:6] = sec % 3;
				//temp = min % 3;
				led_temp[15:14] = min % 3;
				led_temp = led_temp >> 2;
				sec = sec / 3;
				min = min / 3;
			end
			/*for(i = 4; i < 8; i = i+1) begin
				//temp = min % 3;
				led_temp[15:14] = min % 3;
				led_temp = led_temp >> 2;
				min = min / 3;
			end*/
			
			led_state = 24'd0;
			temp = led_temp;
			
			
			
			
			for(i = 0; i < 8; i = i+1) begin
				case (led_temp[1:0])
					2'b10: 	led_state = led_state | 24'b10000000_00000000_00000000;
					2'b01: 	led_state = led_state | 24'b00000000_10000000_00000000;
					//2'b00: 	led_state = led_state | 24'b00000000_00000000_10000000;
					default: led_state = led_state | 24'b00000000_00000000_00000000;
				endcase
				/*
				if(led_temp[1:0] == 2'd2) begin
					led_state = led_state | 24'b10000000_00000000_00000000;
				end
				else if(led_temp[1:0] == 2'd1) begin
					led_state = led_state | 24'b00000000_10000000_00000000;
				end
				else if(led_temp[1:0] == 2'd0) begin
					led_state = led_state | 24'b00000000_00000000_10000000;
				end
				else begin
					led_state = led_state | 24'b00000000_00000000_00000000;
				end*/
				if(i < 7) begin
					led_temp = led_temp >> 2;
					led_state = led_state >> 1;
				end
			end
			
		end
	end

endmodule
